Button
1. Write standard firmata to the device
Uploading Standard Firmata to Arduino
Open Arduino IDE.
File > Examples > Firmata > StandardFirmata
.
Tools > Board > your board
Tools > Serial Port > your port
Click Upload button. if you use WSL, you need to follow this
2. Run the Button
index.tsx
import { Board, Led, Button, render} from "edison"
import React, {useState} from "react"
const App: React.FC = () => {
const [ledOne, setLedOne] = useState(false)
return (
<Board port={'/dev/tty***'} baudRate={57600}>
<Button
pin={8}
triggered={() => setLedOne(true)}
untriggered={() => setLedOne(false)}
>
<Led
pin={13}
isOn={ledOne}
/>
</Button>
</Board>
)
}
render(<App />)
This program will blink the LED when the button is run.
3. execute the program
$ npx vite-node index.tsx
You can use <Button >
Props | Type | Description | Default |
---|---|---|---|
pin | number | Pin number to control current | None |
triggered? | (() => void) | Function executed when a button is pressed | None |
untriggered? | (() => void) | Function executed when the button is released | None |
debounceTime? | number | Delay for a specified period of time | None |
children | React.ReactNode | Child components such as outbut | None |